home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1994 / MacHack 1994.toast / MacHack™ 1987-1994 / MacHack™ '87 / Source ƒ.sea / Source ƒ / emacs source ƒ / HP110.C < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-28  |  3.7 KB  |  220 lines  |  [TEXT/MARC]

  1. /*
  2.  *    HP110:    Hewlett Packard 110 Screen Driver
  3.  */
  4.  
  5. #define    termdef    1            /* don't define "term" external */
  6.  
  7. #include        <stdio.h>
  8. #include    "estruct.h"
  9. #include        "edef.h"
  10.  
  11. #if     HP110
  12.  
  13. #define NROW    16                      /* Screen size.                 */
  14. #define NCOL    80                      /* Edit if you want to.         */
  15. #define    NPAUSE    100            /* # times thru update to pause */
  16. #define    MARGIN    8            /* size of minimim margin and    */
  17. #define    SCRSIZ    64            /* scroll size for extended lines */
  18. #define BEL     0x07                    /* BEL character.               */
  19. #define ESC     0x1B                    /* ESC character.               */
  20.  
  21. extern  int     ttopen();               /* Forward references.          */
  22. extern  int     ttgetc();
  23. extern  int     ttputc();
  24. extern  int     ttflush();
  25. extern  int     ttclose();
  26. extern  int     h110move();
  27. extern  int     h110eeol();
  28. extern  int     h110eeop();
  29. extern  int     h110beep();
  30. extern  int     h110open();
  31. extern    int    h110rev();
  32. extern    int    h110close();
  33. extern    int    h110kopen();
  34. extern    int    h110kclose();
  35.  
  36. #if    COLOR
  37. extern    int    h110fcol();
  38. extern    int    h110bcol();
  39.  
  40. int    cfcolor = -1;        /* current forground color */
  41. int    cbcolor = -1;        /* current background color */
  42. #endif
  43.  
  44. /*
  45.  * Standard terminal interface dispatch table. Most of the fields point into
  46.  * "termio" code.
  47.  */
  48. TERM    term    = {
  49.         NROW-1,
  50.         NCOL,
  51.     MARGIN,
  52.     SCRSIZ,
  53.     NPAUSE,
  54.         h110open,
  55.         h110close,
  56.     h110kopen,
  57.     h110kclose,
  58.         ttgetc,
  59.         ttputc,
  60.         ttflush,
  61.         h110move,
  62.         h110eeol,
  63.         h110eeop,
  64.         h110beep,
  65.     h110rev
  66. #if    COLOR
  67.     , h110fcol,
  68.     h110bcol
  69. #endif
  70. };
  71.  
  72. #if    COLOR
  73. h110fcol(color)        /* set the current output color */
  74.  
  75. int color;    /* color to set */
  76.  
  77. {
  78.     if (color == cfcolor)
  79.         return;
  80.     ttputc(ESC);
  81.     ttputc('[');
  82.     h110parm(color+30);
  83.     ttputc('m');
  84.     cfcolor = color;
  85. }
  86.  
  87. h110bcol(color)        /* set the current background color */
  88.  
  89. int color;    /* color to set */
  90.  
  91. {
  92.     if (color == cbcolor)
  93.         return;
  94.     ttputc(ESC);
  95.     ttputc('[');
  96.     h110parm(color+40);
  97.     ttputc('m');
  98.         cbcolor = color;
  99. }
  100. #endif
  101.  
  102. h110move(row, col)
  103. {
  104.         ttputc(ESC);
  105.         ttputc('[');
  106.         h110parm(row+1);
  107.         ttputc(';');
  108.         h110parm(col+1);
  109.         ttputc('H');
  110. }
  111.  
  112. h110eeol()
  113. {
  114.         ttputc(ESC);
  115.         ttputc('[');
  116.     ttputc('0');
  117.         ttputc('K');
  118. }
  119.  
  120. h110eeop()
  121. {
  122. #if    COLOR
  123.     h110fcol(gfcolor);
  124.     h110bcol(gbcolor);
  125. #endif
  126.         ttputc(ESC);
  127.         ttputc('[');
  128.     ttputc('0');
  129.         ttputc('J');
  130. }
  131.  
  132. h110rev(state)        /* change reverse video state */
  133.  
  134. int state;    /* TRUE = reverse, FALSE = normal */
  135.  
  136. {
  137. #if    COLOR
  138.     int ftmp, btmp;        /* temporaries for colors */
  139. #endif
  140.  
  141.     ttputc(ESC);
  142.     ttputc('[');
  143.     ttputc(state ? '7': '0');
  144.     ttputc('m');
  145. #if    COLOR
  146.     if (state == FALSE) {
  147.         ftmp = cfcolor;
  148.         btmp = cbcolor;
  149.         cfcolor = -1;
  150.         cbcolor = -1;
  151.         h110fcol(ftmp);
  152.         h110bcol(btmp);
  153.     }
  154. #endif
  155. }
  156.  
  157. h110beep()
  158. {
  159.         ttputc(BEL);
  160.         ttflush();
  161. }
  162.  
  163. h110parm(n)
  164. register int    n;
  165. {
  166.         register int q,r;
  167.  
  168.         q = n/10;
  169.         if (q != 0) {
  170.         r = q/10;
  171.         if (r != 0) {
  172.             ttputc((r%10)+'0');
  173.         }
  174.         ttputc((q%10) + '0');
  175.         }
  176.         ttputc((n%10) + '0');
  177. }
  178.  
  179. h110open()
  180. {
  181.     revexist = TRUE;
  182.         ttopen();
  183. }
  184.  
  185. h110close()
  186.  
  187. {
  188. #if    COLOR
  189.     h110fcol(7);
  190.     h110bcol(0);
  191. #endif
  192.     ttclose();
  193. }
  194.  
  195. h110kopen()
  196.  
  197. {
  198. }
  199.  
  200. h110kclose()
  201.  
  202. {
  203. }
  204.  
  205. #if    FLABEL
  206. fnclabel(f, n)        /* label a function key */
  207.  
  208. int f,n;    /* default flag, numeric argument [unused] */
  209.  
  210. {
  211.     /* on machines with no function keys...don't bother */
  212.     return(TRUE);
  213. }
  214. #endif
  215. #else
  216. h110hello()
  217. {
  218. }
  219. #endif
  220.